package com.example.apidocserver.infrastructure.enums;

import com.alibaba.druid.util.StringUtils;
import lombok.Getter;

/**
 * 用户历史id类型
 *
 * @author xyqlg
 */
@Getter
public enum HisIdEnum {
    /**
     * 枚举
     */
    ALL("all", "所有入参"),
    SPACE("space", "空间"),
    ENV("env", "环境"),
    DOC("doc", "文档"),
    API("api", "接口"),
    HIS("his", "参数示例");

    private HisIdEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    private final String code;
    private final String desc;

    public static HisIdEnum getEnumByCode(String type) {
        if (StringUtils.isEmpty(type)) {
            return null;
        }
        for (HisIdEnum value : HisIdEnum.values()) {
            if (value.getCode().equals(type)) {{
                return value;
            }}
        }
        return null;
    }
}
